<?php
/**
 * @name /www/admin/users.php
 * @author
 * @version 2011.03.30
 *
 * This is the admin page to show list of users.
 */

// Sets up configuration settings and includes libraries.
require_once('_ini.php');

// Libraries
ReqLib('/lib/private/User.php');


function DefineHeader() {
?><script type="text/javascript">
  $(function() {
    $('#Users').dataTable({
      'bJQueryUI': true,
      'sPaginationType': 'full_numbers'
    });
  });
</script>
<?
}

/**
 * Defines page content.
 *
 */
function DefineContent()
{
  // Page content goes here.
  ?>
<p>
  <a href="<?=_webroot('/') ?>">Home</a>.
</p>
<?
	if($_SESSION['userId'] >0){
?>
		<p>
		  <a href="<?=_webroot('/account.php') ?>">My Account</a>.
		</p>
		<p>
		  <a href="<?=_webroot('/logout.php') ?>">Logout</a>.
		</p>
<center>
<div style="width: 800px; margin-left: auto; margin-right: auto;">
<table class="display" id="Users" cellpadding="5" cellspacing="0" border="1">
		<thead>
			<th>User Id</th>
			<th>User Name</th>
    </thead>
    <tbody>
<?

	foreach(User::GetUsers($_GET['Param1'], $_GET['Param2']) as $u)
	{
		println('<tr>');
		println("<td><a href=edituser.php?uId={$u->UserId}>{$u->UserId}</a></td><td>{$u->UserName}</td>");
		println('</tr>');
	}

	println('</tbody></table></div></center>');

 }
   else{
?>
		<p>
		  <a href="<?=_webroot('/login_register.php') ?>">Login/Register</a>.
		</p>
<?
   }
}

// Launches the page; without this, nothing happens.
require_once('_loader.php');